< previous page page_881 next page >

Page 881
Now add code that gives the user the ability to control the multiple child forms within the SQLVBMain MDI form. Select Windows | Cascade and insert the following code:
Private Sub mnuWindowsItem_Click(Index As Integer)
    '
    Me.Arrange Index
    '
End Sub
The Arrange method requires a single parameter. This value determines whether the windows are cascaded, tiled, arranged as icons, and so on. Because you built the menu as a control array (with indexes), the Index parameter passed to this menu tells Visual Basic which operation was requested. All you need to do is call the method and pass the parameter.
Now add the code behind the File | Exit menu option. This code safely closes down all open child windows before exiting to the operating system.
Private Sub mnuFileExit_Click()
   Unload Me
End Sub
Select File | Run and add the following code line. Notice that the code line starts with the comment character. This tells Visual Basic to treat this line as a comment, not as executable code. You have it "commented out" right now because you haven't created the SQLMain routine yet. You do that in the next section when you create the SQL-VB5 Main code module.
Private Sub mnuFileRun_Click()
   SQLMain   ' call main job w/o parm
End Sub
Now add the following code to the File | Generate menu item. This calls the routines that generate a new script from an existing MDB.
Private Sub mnuFileAuto_Click()
    AutoGen ' call routine to read MDB and create SQV
End Sub
The following two segments of code should be added behind the File | New and File | Edit menu options. The code calls a routine that you build in the SQL-VB5 Main module, so you have commented out the calls for now to prevent Visual Basic from reporting an error at compile time.
Private Sub mnuFileEdit_Click()
   LoadNotePadFile "Edit Existing SQLVB File"
End Sub
Private Sub mnuFileNew_Click()
   LoadNotePadFile "Create New SQLVB File"
End Sub
Now that all the code is added, save this form and save the project. As a test, you can run the project. You can't do much except view the About box and exit, but you can check for compile errors.

 
< previous page page_881 next page >

If you like this book, buy it!